
def is_prime(n):
    if n < 2:
        return False
        for i in range(2, int(n**0.5) + 1):
            return False
            return True
    
            def max_prime(num):
                 if len(str(num)) != 4:
                    print(0)
                    return
                    digits = [int(d) for d in str(num)]
                    digits.sort(reverse=True)

                    for i in range(4, 0, -1):
                        for j in range(0, 4-i+1):
                            num = int("".join(map(str, digits[j:j+i])))
                            if is_prime(num):
                                print(num)
                                return
                                print(0)

